Plotting Density of States

In this short tutorial we will inspect the basic features of the DoS module of PyBigDFT. We employ two runs as demonstrator of the comparison between two runs. A Bulk run of a AlN system, followed by a Vacancy run. The Vacancy is also provided with a Spin Collinear run, for comparison.

from BigDFT import Logfiles as L
Vacancy = L.Logfile('/home/genovese/Downloads/VN2_last.log')
Bulk = L.Logfile('/home/genovese/Downloads/AlN_last.log')
VacancySpin = L.Logfile('/home/genovese/Downloads/VNspin_last.log')

Description of the tests done

We will shot how to 1. Plot the DoS with the plot commodity function; 2. Get the curves from a get_curve function; 4. Handle those curves for external plotting; 3. Shifts the values of the curves wrt to a constant, or a dictionary of shifts;

Simple plots of the two runs

We here show how the two runs behave.


Plot a DoS of a collinear Spin calculation

_=VacancySpin.get_dos().plot().set_title('Vacancy, Collinear Spin')
from BigDFT.DoS import DoS
dosspin = DoS(logfiles_dict={'SA':Vacancy, 'SC':VacancySpin})

Note the modification of the labels from the original definition.

['SA', 'SCup', 'SCdw']

Plot of the two DoS together

We would like to compare the two runs. It is possible to instanciate a DoS class.

from BigDFT.DoS import DoS
dos = DoS(logfiles_dict={'Vacancy': Vacancy, 'Bulk': Bulk},
          fermi_level=Vacancy.fermi_level,units='AU') # last two as an option
<matplotlib.axes._subplots.AxesSubplot at 0x7f49540ac3c8>

The above plot show the tow DoS together. We may select a region:

ax= dos.plot()
ax.set_title('Plot with two DoS, aligned and cropped')
ax.annotate('Note the fermi_level here', xytext=(8,160), xy=(dos.ef,100), arrowprops = dict(arrowstyle='->'))
Text(8, 160, 'Note the fermi_level here')
ax= dos.plot()
ax.set_title('Plot with two DoS, cropped externally')

(6, 8)

Handle the curves explicitly

Perform the difference between the curves and plot it

from matplotlib import pyplot as plt
dos.set_range(e_min=-100,e_max=100) # restore full range
curves = dos.get_curves()
x,yB = curves['Bulk']
x,yV = curves['Vacancy']
plt.plot(x,yV-yB,label='DoS differences')
<matplotlib.legend.Legend at 0x7f4953f2b518>

Shift the curves and plot them shifted

ax.set_title('Full plot with dos shifted')
Text(0.5, 1.0, 'Full plot with dos shifted')

Handle curves from spin-polarized calculations

We show also an example on customized plots where DoS differences are plot next to the original curves.

curves = dosspin.get_curves()
differences = {'up-down': curves['SCup'].y + curves['SCdw'].y,
               'Noncollinear-Collinear': curves['SA'].y - curves['SCup'].y}
x = dosspin.range
from matplotlib import pyplot as plt
fig, (axT, axD) = plt.subplots(1,2,figsize=(12,4))
axT.set_title('Total DoS')
for label, curve in differences.items():